/*
 * Principal.java
 *
 * Created on 19 de abril de 2008, 15:07
 */

package GUI;

import ReglasNegocio.*;
import AccesoDatos.*;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.JOptionPane;
import net.sf.jasperreports.view.JasperViewer;

import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.view.JRViewer;

import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import java.io.File;
import java.sql.*;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author  Hugol
 * modificado por ramayac
 */
public class frmPrincipal extends javax.swing.JFrame {
    
    /** Creates new form Principal */
       
    public frmPrincipal(Usuario usuario, JFrame jFrame) {        
        initComponents();     
        this.setLocationRelativeTo(null);
        
         try{
            UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceCremeCoffeeLookAndFeel");
        }
        catch(Exception e) {/*ni mix*/}
        
        LlenarGrid();
        
        if (usuario.getGerente()!=null){
            this.lblNombre.setText("Bienvenido: "+usuario.getGerente().getNombres() + " " + usuario.getGerente().getApellidos());
        }
        else{
            this.lblNombre.setText("Bienvenido: "+usuario.getMandador().getNombres() + " " + usuario.getMandador().getApellidos());      
        }
        
        
    }

    public void LlenarGrid(){
        DefaultTableModel datos=new DefaultTableModel(); 
        //Creo las columnas que llevara el jTable
        datos.addColumn("Fecha");
        datos.addColumn("Nombre Actividad");  
        datos.addColumn("Área Cubierta");
        datos.addColumn("Número de Personal");
        datos.addColumn("Finca");

        //Asignamos el model de datos a su respectivo jTable
        this.jTable2.setModel(datos);
        
        ConMySQL con=new ConMySQL();
        con.Conectar();
        String buscar="SELECT * FROM log_actividad";
        Vista v=con.crearVista(buscar);
        if (v.getNRegistros()>0) {
            for(int i=0;i<v.getNRegistros();i++) {
                long idm=(Long)v.getRegistro(i, 0);
                Dato id=new Dato("id",String.valueOf(idm));
                logActividad l=new logActividad(id);
                String[] fila={l.getFecha().toString(),l.getFkactividad().getNombre(),Long.toString((long)l.getAreacubierta()),Long.toString((long)l.getNumpersonas()),l.getFkfinca().getNombre()};
                System.out.print(fila);
                datos.addRow(fila);
            }
        }
        
    }
    
    private frmPrincipal() {
        throw new UnsupportedOperationException("Not yet implemented");
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jLabel2 = new javax.swing.JLabel();
        lblNombre = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem11 = new javax.swing.JMenuItem();
        jMenuItem12 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        jMenuItem10 = new javax.swing.JMenuItem();
        jMenu6 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu7 = new javax.swing.JMenu();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenu8 = new javax.swing.JMenu();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        ArrobasRecolecMoz = new javax.swing.JMenuItem();
        DetalleInsumoAct = new javax.swing.JMenuItem();
        jMenu9 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem14 = new javax.swing.JMenuItem();
        jMenuItem15 = new javax.swing.JMenuItem();
        jMenuItem16 = new javax.swing.JMenuItem();
        jMenuItem17 = new javax.swing.JMenuItem();
        ActFinca = new javax.swing.JMenu();
        KiliRep = new javax.swing.JMenuItem();
        LosNaranjRep = new javax.swing.JMenuItem();
        GaliciaRep = new javax.swing.JMenuItem();
        HimaRep = new javax.swing.JMenuItem();
        CortAnyoActual = new javax.swing.JMenuItem();
        CortAnyoAnterior = new javax.swing.JMenuItem();
        CortMesActu = new javax.swing.JMenuItem();
        TotTrabporFinca = new javax.swing.JMenuItem();
        TotMozoporFinca = new javax.swing.JMenuItem();
        GastosViaticGer = new javax.swing.JMenuItem();
        GastoDistRecoGer = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem13 = new javax.swing.JMenuItem();

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Fincafe");
        setFont(new java.awt.Font("Agency FB", 1, 24)); // NOI18N

        jLabel1.setFont(new java.awt.Font("Segoe UI", 0, 24));
        jLabel1.setText("Kilimanjaro, S.A. de C.V.");

        jLabel3.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
        jLabel3.setText("Tareas de Invierno:");

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Fecha", "Nombre Actividad", "Área cubierta", "# Personal", "Finca"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane2.setViewportView(jTable2);

        jLabel2.setFont(new java.awt.Font("Segoe UI", 0, 24)); // NOI18N
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Sistema de Información de labores de cultivo (precosecha)");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 982, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 982, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(837, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE))
        );

        lblNombre.setFont(new java.awt.Font("Segoe UI", 1, 15)); // NOI18N
        lblNombre.setText("Usuario");

        jMenuBar1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/computer_off.png"))); // NOI18N
        jMenu1.setMnemonic('A');
        jMenu1.setText("Archivo");

        jMenuItem11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/user_cross.png"))); // NOI18N
        jMenuItem11.setText("Cerrar Sesión");
        jMenuItem11.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jMenuItem11MousePressed(evt);
            }
        });
        jMenu1.add(jMenuItem11);

        jMenuItem12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/bullet_cross.png"))); // NOI18N
        jMenuItem12.setText("Salir");
        jMenuItem12.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jMenuItem12MousePressed(evt);
            }
        });
        jMenu1.add(jMenuItem12);

        jMenuBar1.add(jMenu1);

        jMenu2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/application_osx_home.png"))); // NOI18N
        jMenu2.setMnemonic('F');
        jMenu2.setText("Finca");

        jMenuItem6.setText("Fincas");
        jMenuItem6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jMenuItem6MouseClicked(evt);
            }
        });
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem6);

        jMenuBar1.add(jMenu2);

        jMenu5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/application_osx_lightning.png"))); // NOI18N
        jMenu5.setMnemonic('C');
        jMenu5.setText("Corte");

        jMenuItem10.setText("Producción Diaria");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem10);

        jMenuBar1.add(jMenu5);

        jMenu6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/user_tick.png"))); // NOI18N
        jMenu6.setMnemonic('R');
        jMenu6.setText("Recurso Humano");

        jMenuItem1.setText("Administrador");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu6.add(jMenuItem1);

        jMenuItem9.setText("Mandador");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu6.add(jMenuItem9);

        jMenuItem2.setText("Mozo");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu6.add(jMenuItem2);

        jMenuItem4.setText("Planilla");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu6.add(jMenuItem4);

        jMenuItem5.setText("Recurso Humano");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu6.add(jMenuItem5);

        jMenuBar1.add(jMenu6);

        jMenu7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/application_osx_link.png"))); // NOI18N
        jMenu7.setMnemonic('t');
        jMenu7.setText("Actividades");

        jMenuItem7.setText("Actividad");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu7.add(jMenuItem7);

        jMenuBar1.add(jMenu7);

        jMenu8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/application_osx_get.png"))); // NOI18N
        jMenu8.setMnemonic('I');
        jMenu8.setText("Insumos");

        jMenuItem8.setText("Insumos");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu8.add(jMenuItem8);

        jMenuBar1.add(jMenu8);

        jMenu4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/application_osx_cascade.png"))); // NOI18N
        jMenu4.setMnemonic('n');
        jMenu4.setText("Informes");

        ArrobasRecolecMoz.setMnemonic('A');
        ArrobasRecolecMoz.setText("Arrobas recolectadas por Mozo");
        ArrobasRecolecMoz.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                ArrobasRecolecMozMousePressed(evt);
            }
        });
        jMenu4.add(ArrobasRecolecMoz);

        DetalleInsumoAct.setMnemonic('D');
        DetalleInsumoAct.setText("Detalle de insumo por actividad");
        DetalleInsumoAct.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                DetalleInsumoActMousePressed(evt);
            }
        });
        jMenu4.add(DetalleInsumoAct);

        jMenu9.setMnemonic('V');
        jMenu9.setText("Visitas Gerentes");

        jMenuItem3.setText("Gerente 1");
        jMenuItem3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jMenuItem3MousePressed(evt);
            }
        });
        jMenu9.add(jMenuItem3);

        jMenuItem14.setText("Gerente 2");
        jMenuItem14.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jMenuItem14MousePressed(evt);
            }
        });
        jMenu9.add(jMenuItem14);

        jMenuItem15.setText("Gerente 3");
        jMenuItem15.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jMenuItem15MousePressed(evt);
            }
        });
        jMenu9.add(jMenuItem15);

        jMenuItem16.setText("Gerente 4");
        jMenuItem16.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jMenuItem16MousePressed(evt);
            }
        });
        jMenu9.add(jMenuItem16);

        jMenuItem17.setText("Gerente 5");
        jMenuItem17.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jMenuItem17MousePressed(evt);
            }
        });
        jMenu9.add(jMenuItem17);

        jMenu4.add(jMenu9);

        ActFinca.setMnemonic('F');
        ActFinca.setText("Actividades de la Finca");

        KiliRep.setText("Kilimanjaro");
        KiliRep.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                KiliRepMousePressed(evt);
            }
        });
        ActFinca.add(KiliRep);

        LosNaranjRep.setText("Los Naranjos");
        LosNaranjRep.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                LosNaranjRepMousePressed(evt);
            }
        });
        ActFinca.add(LosNaranjRep);

        GaliciaRep.setText("Galicia");
        GaliciaRep.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                GaliciaRepMousePressed(evt);
            }
        });
        ActFinca.add(GaliciaRep);

        HimaRep.setText("Himalaya");
        HimaRep.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                HimaRepMousePressed(evt);
            }
        });
        ActFinca.add(HimaRep);

        jMenu4.add(ActFinca);

        CortAnyoActual.setText("Corte Año Actual");
        CortAnyoActual.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                CortAnyoActualMousePressed(evt);
            }
        });
        jMenu4.add(CortAnyoActual);

        CortAnyoAnterior.setText("Corte Año Anterior");
        CortAnyoAnterior.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                CortAnyoAnteriorMousePressed(evt);
            }
        });
        jMenu4.add(CortAnyoAnterior);

        CortMesActu.setText("Cortes del Mes Actual");
        CortMesActu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                CortMesActuMousePressed(evt);
            }
        });
        jMenu4.add(CortMesActu);

        TotTrabporFinca.setText("Total Trabajadores por Finca");
        TotTrabporFinca.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                TotTrabporFincaMousePressed(evt);
            }
        });
        jMenu4.add(TotTrabporFinca);

        TotMozoporFinca.setText("Total Mozos por Finca");
        TotMozoporFinca.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                TotMozoporFincaMousePressed(evt);
            }
        });
        jMenu4.add(TotMozoporFinca);

        GastosViaticGer.setText("Gastos en Viaticos de los Gerentes");
        GastosViaticGer.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                GastosViaticGerMousePressed(evt);
            }
        });
        jMenu4.add(GastosViaticGer);

        GastoDistRecoGer.setText("Distancia Recorrida por los Gerentes");
        GastoDistRecoGer.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                GastoDistRecoGerMousePressed(evt);
            }
        });
        jMenu4.add(GastoDistRecoGer);

        jMenuBar1.add(jMenu4);

        jMenu3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/cup_black.png"))); // NOI18N
        jMenu3.setText("Ayuda");

        jMenuItem13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/star_bronze.png"))); // NOI18N
        jMenuItem13.setText("Acerca de...");
        jMenuItem13.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jMenuItem13MousePressed(evt);
            }
        });
        jMenu3.add(jMenuItem13);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblNombre)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 678, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addContainerGap())
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblNombre)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
private void ArrobasRecolecMozMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ArrobasRecolecMozMousePressed
llamarReporte("arrobas_recolectadas_pormozo.jasper");
}//GEN-LAST:event_ArrobasRecolecMozMousePressed

private void DetalleInsumoActMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DetalleInsumoActMousePressed
llamarReporte("insumos_por_actividad.detalle.jasper");
}//GEN-LAST:event_DetalleInsumoActMousePressed

private void CortAnyoActualMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CortAnyoActualMousePressed
llamarReporte("Cortes_del_AnyoActual.jasper");
}//GEN-LAST:event_CortAnyoActualMousePressed

private void CortAnyoAnteriorMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CortAnyoAnteriorMousePressed
llamarReporte("Cortes_del_AnyoAnterior.jasper");
}//GEN-LAST:event_CortAnyoAnteriorMousePressed

private void CortMesActuMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CortMesActuMousePressed
llamarReporte("Cortes_del_MesActual.jasper");
}//GEN-LAST:event_CortMesActuMousePressed

private void TotTrabporFincaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TotTrabporFincaMousePressed
llamarReporte("total_trabajadores_por_finca.jasper");
}//GEN-LAST:event_TotTrabporFincaMousePressed

private void TotMozoporFincaMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TotMozoporFincaMousePressed
llamarReporte("total_mozos_por_finca.jasper");
}//GEN-LAST:event_TotMozoporFincaMousePressed

private void KiliRepMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_KiliRepMousePressed
llamarReporte("kili.actividades.detalle.jasper");
}//GEN-LAST:event_KiliRepMousePressed

private void LosNaranjRepMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LosNaranjRepMousePressed
llamarReporte("nara.actividades.detalle.jasper");
}//GEN-LAST:event_LosNaranjRepMousePressed

private void GaliciaRepMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_GaliciaRepMousePressed
llamarReporte("gali.actividades.detalle.jasper");
}//GEN-LAST:event_GaliciaRepMousePressed

private void HimaRepMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_HimaRepMousePressed
llamarReporte("hima.actividades.detalle.jasper");
}//GEN-LAST:event_HimaRepMousePressed

private void GastosViaticGerMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_GastosViaticGerMousePressed
llamarReporte("Gasto_Viaticos_Gerentes.jasper");
}//GEN-LAST:event_GastosViaticGerMousePressed

private void GastoDistRecoGerMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_GastoDistRecoGerMousePressed
llamarReporte("Gasto_Distancia_Gerentes.jasper");
}//GEN-LAST:event_GastoDistRecoGerMousePressed

private void jMenuItem6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem6MouseClicked
  
//NADA    
}//GEN-LAST:event_jMenuItem6MouseClicked

private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
    
    frmFinca f= new frmFinca();
    f.pack();
    f.setVisible(true);
    
}//GEN-LAST:event_jMenuItem6ActionPerformed

private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed

    frmProduccionDiaria f= new frmProduccionDiaria();
    f.pack();
    f.setVisible(true);

}//GEN-LAST:event_jMenuItem10ActionPerformed

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
    frmAdministrador f= new frmAdministrador();
    f.pack();
    f.setVisible(true);

}//GEN-LAST:event_jMenuItem1ActionPerformed

private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
    frmMandador f= new frmMandador();
    f.pack();
    f.setVisible(true);

}//GEN-LAST:event_jMenuItem9ActionPerformed

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
    frmMozo f= new frmMozo();
    f.pack();
    f.setVisible(true);

}//GEN-LAST:event_jMenuItem2ActionPerformed

private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
    frmPlanilla f= new frmPlanilla();
    f.pack();
    f.setVisible(true);

}//GEN-LAST:event_jMenuItem4ActionPerformed

private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
    frmRecursoHumano f= new frmRecursoHumano();
    f.pack();
    f.setVisible(true);

}//GEN-LAST:event_jMenuItem5ActionPerformed

private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
    frmActividad f= new frmActividad();
    f.pack();
    f.setVisible(true);

}//GEN-LAST:event_jMenuItem7ActionPerformed

private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
    frmInsumo f= new frmInsumo();
    f.pack();
    f.setVisible(true);

}//GEN-LAST:event_jMenuItem8ActionPerformed

private void jMenuItem11MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem11MousePressed
int decision=JOptionPane.showConfirmDialog(this, "¿Está seguro que desea cerrar sesión?");
        if (decision==0){
            this.dispose();
            frmLogin newPeople = new frmLogin();
            newPeople.setVisible(true);
        }
}//GEN-LAST:event_jMenuItem11MousePressed

private void jMenuItem12MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem12MousePressed
System.exit(0);
}//GEN-LAST:event_jMenuItem12MousePressed

private void jMenuItem13MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem13MousePressed
GUI.frmAcercaDe frm = new GUI.frmAcercaDe();
frm.setVisible(true);
}//GEN-LAST:event_jMenuItem13MousePressed

private void jMenuItem3MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem3MousePressed
llamarReporte("log_visitas.ger1.detalle.jasper");
}//GEN-LAST:event_jMenuItem3MousePressed

private void jMenuItem14MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem14MousePressed
llamarReporte("log_visitas.ger2.detalle.jasper");
}//GEN-LAST:event_jMenuItem14MousePressed

private void jMenuItem15MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem15MousePressed
llamarReporte("log_visitas.ger3.detalle.jasper");
}//GEN-LAST:event_jMenuItem15MousePressed

private void jMenuItem16MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem16MousePressed
llamarReporte("log_visitas.ger4.detalle.jasper");
}//GEN-LAST:event_jMenuItem16MousePressed

private void jMenuItem17MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuItem17MousePressed
llamarReporte("log_visitas.ger5.detalle.jasper");
}//GEN-LAST:event_jMenuItem17MousePressed


    public void llamarReporte(String nombreReporte) {
    try{
        File reporte = new File("build"+File.separatorChar+
                "classes"+File.separatorChar+
                "Reportes"+File.separatorChar+nombreReporte);
        reporte = reporte.getAbsoluteFile();
        JasperReport jasperReport = (JasperReport)JRLoader.loadObject(reporte.toString());//JasperCompileManager.compileReport(reporte.toString());
        Connection conn = null;
        String userName = "fincafe";
        String password = "cafejava";
        String url = "jdbc:mysql://localhost:3306/fincafe";
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        conn = DriverManager.getConnection(url, userName, password);
        System.out.println("Yey! me conecte :)");
        JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, conn);
       // JRViewer jv = new net.sf.jasperreports.view.JRViewer(jasperPrint);
        net.sf.jasperreports.view.JasperViewer jv = new net.sf.jasperreports.view.JasperViewer(jasperPrint, false);
        jv.setVisible(true);
        //JasperViewer.viewReport(jasperPrint);

     }catch(Exception ex) {
           String msg = "No pude crear el reporte " + ex.getMessage() + " " + ex.getLocalizedMessage();
           System.out.println(msg);
     }
}
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new frmPrincipal().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu ActFinca;
    private javax.swing.JMenuItem ArrobasRecolecMoz;
    private javax.swing.JMenuItem CortAnyoActual;
    private javax.swing.JMenuItem CortAnyoAnterior;
    private javax.swing.JMenuItem CortMesActu;
    private javax.swing.JMenuItem DetalleInsumoAct;
    private javax.swing.JMenuItem GaliciaRep;
    private javax.swing.JMenuItem GastoDistRecoGer;
    private javax.swing.JMenuItem GastosViaticGer;
    private javax.swing.JMenuItem HimaRep;
    private javax.swing.JMenuItem KiliRep;
    private javax.swing.JMenuItem LosNaranjRep;
    private javax.swing.JMenuItem TotMozoporFinca;
    private javax.swing.JMenuItem TotTrabporFinca;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenu jMenu7;
    private javax.swing.JMenu jMenu8;
    private javax.swing.JMenu jMenu9;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem11;
    private javax.swing.JMenuItem jMenuItem12;
    private javax.swing.JMenuItem jMenuItem13;
    private javax.swing.JMenuItem jMenuItem14;
    private javax.swing.JMenuItem jMenuItem15;
    private javax.swing.JMenuItem jMenuItem16;
    private javax.swing.JMenuItem jMenuItem17;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JLabel lblNombre;
    // End of variables declaration//GEN-END:variables
    
}
